<MonitorWindow:TeamMemberBadgeBase x:Class="ScrumSprintMonitor.UI.Wpf.Views.MonitorWindow.UnassignedTeamMemberBadge"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:ScrumSprintMonitor.UI.Wpf" 
    xmlns:converters="clr-namespace:ScrumSprintMonitor.UI.Wpf.Converters" 
    xmlns:MonitorWindow="clr-namespace:ScrumSprintMonitor.UI.Wpf.Views.MonitorWindow"
    mc:Ignorable="d"
    Padding="6">

    <MonitorWindow:TeamMemberBadgeBase.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\..\Styles\TeamMemberBaseStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <converters:WorkTimeRatioBrushValueConverter x:Key="WorkTimeRatioBrushValueConverter" />
            
            <local:XamlServiceLocator x:Key="serviceLocator" />
        </ResourceDictionary>
    </MonitorWindow:TeamMemberBadgeBase.Resources>

    <MonitorWindow:TeamMemberBadgeBase.DataContext>
        <Binding Path="TeamMembersListViewModel.UnassignedWork" Source="{StaticResource serviceLocator}"/>
    </MonitorWindow:TeamMemberBadgeBase.DataContext>

    <MonitorWindow:TeamMemberBadgeBase.Style>
        <StaticResource ResourceKey="BaseTeamMemberStyle"/>
    </MonitorWindow:TeamMemberBadgeBase.Style>

    <Grid Style="{StaticResource GlowOnUpdateStyle}">
        <UserControl Template="{StaticResource GlassPanel}">
            <UserControl.Background>
                <MultiBinding Converter="{StaticResource WorkTimeRatioBrushValueConverter}" ConverterParameter="Background">
                    <Binding Path="RemainingSprintWorkWithUnassigned" />
                    <Binding Path="RemainingSprintHours" />
                </MultiBinding>
            </UserControl.Background>

            <UserControl.Foreground>
                <MultiBinding Converter="{StaticResource WorkTimeRatioBrushValueConverter}" ConverterParameter="Foreground">
                    <Binding Path="RemainingSprintWorkWithUnassigned"/>
                    <Binding Path="RemainingSprintHours"/>
                </MultiBinding>
            </UserControl.Foreground>

            <Grid Margin="16">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.ColumnSpan="2" Style="{StaticResource TeamMemberNameLabel}" Text="{Binding Path=DisplayName}" />

                <TextBlock Grid.Row="1" Style="{StaticResource InfoLabel}">Open Backlog Items:</TextBlock>
                <TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource NumericValueLabel}" Text="{Binding Path=RemainingWorkItemCount}" />

                <TextBlock Grid.Row="2" Style="{StaticResource InfoLabel}">Estimated Workload:</TextBlock>
                <TextBlock Grid.Row="2" Grid.Column="1">
                    <TextBlock.Style>
                        <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource NumericValueLabel}">
                            <Setter Property="Text" Value="{Binding Path=RemainingSprintWork, StringFormat='{}{0:N0}h'}" />

                            <Style.Triggers>
                                <DataTrigger Binding="{Binding NotAllWorkItemsEstimated}" Value="True">
                                    <Setter Property="Text" Value="{Binding Path=RemainingSprintWork, StringFormat='{}{0:N0}h+'}" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
            </Grid>
        </UserControl>
    </Grid>
</MonitorWindow:TeamMemberBadgeBase>
